<?php
/**
 * View  LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/js/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript" src="/js/ckeditor/load-editor.js"></script>

<script type="text/javascript">
    //<![CDATA[
     
    $(document).ready(function() {
        
        validator.groups = {day: "dateValid", month: "dateValid", year: "dateValid"}

	// Datepicker
	$( "#year" ).datepicker({
	    // Riempie i campi della data...
	    onSelect: function(dateText, inst) {
		var theDate = new Date(Date.parse($(this).datepicker('getDate')));
		var day = $.datepicker.formatDate('dd', theDate);
		var month = $.datepicker.formatDate('mm', theDate);
		var year = $.datepicker.formatDate('yy', theDate);
		$('#day').val(day);
		$('#month').val(month);
		$('#year').val(year);
	    },
	    showOn: "button",
	    showAnim: 'blind',
	    buttonImage: "/images/admin/calendar.png",
	    buttonImageOnly: true
	});
        
        $("#post_text").rules("add", {
            ckeditor: true,
            messages: {
                ckeditor: "<?php echo ERR_EMPTY ?>"
            }
        });            

        // Risolve un bug d'integrazione tra jQuery e CKeditor
	$("#conferma").click(function(){
            CKEDITOR.instances.post_text.updateElement();
            validator.form();
            return validator.element( "#post_text" );
	});

	$( '#post_text' ).ckeditor(function(){}, ckeditorConf );
        $('#post_text').val('<?php echo (addslashes( $this->live['post']['post_text'] ) ) ?>');
    });

    //]]>
</script>
<div class="info">
    <h2>Inserisci Nuovo Post</h2>
    <div>Per inserire un nuovo post...</div>
    <div>I campi contrassegnati da <span class="req">*</span> sono obbligatori!</div>
</div>
<div id="alerts">
    <noscript>
    <p>
	<strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
				support, like yours, you should still see the contents (HTML data) and you should
				be able to edit it normally, without a rich editor interface.
    </p>
    </noscript>
</div>
<form class="fab" name="postForm" id="postForm" action="/admin/live/post/id/<?php echo $this->live['live_id'] ?>" method="post" enctype="multipart/form-data">
<div id="content">
    <div id="summary" class="live">
	<div class="head live">
	    <h2>Riepilogo Live:</h2>
	</div>
	<div class="body">
	    <table cellspacing="0" class="table">
		<tbody>
		    <tr>
			<th>Artista:</th>
			<td>
			    <strong>
				<?php
				foreach( $this->live['artists']['main'] as $artist ) :
				    $artists_list .= $artist['artist_name'] . ', ';
				endforeach;
				?>
				<?php echo substr( $artists_list, 0, -2 ); ?>
			    </strong>
			</td>
		    </tr>
		    <?php if( count( $this->live['artists']['openingact'] ) ): ?>
    		    <tr>
    			<th>Open-act:</th>
    			<td>
    			    <strong>
				    <?php
				    $artists_list = null;
				    foreach( $this->live['artists']['openingact'] as $artist ) :
					$artists_list .= $artist['artist_name'] . ', ';
				    endforeach;
				    ?>
				    <?php echo substr( $artists_list, 0, -2 ); ?>				
    			    </strong>
    			</td>
    		    </tr>			
		    <?php endif; ?>
		    <tr>
			<th>Location:</th>
			<td><strong><?php echo $this->live['location']['location_name'] ?>, <?php echo $this->live['location']['location_city'] ?> (<?php echo $this->province[$this->live['location']['location_province_id']]['province_short_name'] ?>)</strong></td>
		    </tr>
		    <tr>
			<th>Quando:</th>
			<td><strong><?php echo $this->days[date( 'N', mktime( $hour, $minute, $second, $this->live['live_date_m'], $this->live['live_date_d'], $this->live['live_date_y'] ) )] ?>, <?php echo $this->live['live_date_ita'] ?></strong></td>
		    </tr>
		    <tr class="break">
			<td colspan="2">&nbsp;</td>
		    </tr>
		    <tr>
			<th>Ingresso:</th>
			<td><?php echo $this->live['live_price_1'] ? $this->live['live_price_1'] . ',' . $this->live['live_price_2'] . ' &euro;' : 'gratuito' ?></td>
		    </tr>
		    <tr>
			<th>Apertura Cancelli:</th>
			<td><?php echo $this->live['live_gate_open_h'] ? $this->live['live_gate_open_h'] . 'h' . $this->live['live_gate_open_m'] : '' ?></td>
		    </tr>
		    <tr>
			<th>Note:</th>
			<td><?php echo $this->live['live_notes'] ?></td>
		    </tr>
		    <tr class="live-status">
			<th>Stato:</th>
			<td>
			    <span class="proposal">Proposta</span>
			    <span class="pending">In Attesa</span>
			    <span class="confirmed">Confermato</span>
			    <span class="canceled">Annullato</span>
			</td>
		    </tr>
		</tbody>
	    </table>
	</div>
    </div>
    <br class="clear"/>

    <ul>
        <li class="paging-context ">
            <table class="pgStyle1 circle2" cellspacing="0">
                <tr>
                    <td class="c selected">
                        <var>1</var>
                    </td>
                    <td class="t selected">
                        <b id="pagecircle1">Post</b>
                    </td>
                    <td class="c ">
                        <var>2</var>
                    </td>
                    <td class="t">
                        <b id="pagecircle2">Links</b>
                    </td>
                    <td class="c ">
                        <var>3</var>
                    </td>
                    <td class="t">
                        <b id="pagecircle2">Immagine</b>
                    </td>
                </tr>
            </table>
        </li>            
        <li id="errorLi" style="<?php echo $this->errorMsg ? '' : 'display:none' ?>">
            <h3 id="errorMsgLbl">Si &egrave; verificato un problema durante l'invio del modulo.</h3>
            <p id="errorMsg">
            Di seguito trovi evidenziati gli errori riscontrati.
            </p>
        </li>

        <li class="<?php echo $this->errorMsg['post_text'] ? 'error' : '' ?>">
            <label class="desc <?php echo $this->errorMsg['post_text'] ? 'error' : '' ?>">Testo<span class="req">*</span></label>
            <div>
                <span>
                    <textarea class="editor" id="post_text" name="post_text" rows="10" cols="50"><?php echo htmlentities( $this->data['post_text'] ) ?></textarea>
                </span>
            </div>
            <p class="error" style="<?php echo $this->errorMsg['post_text'] ? 'display:block' : '' ?>"><?php echo $this->errorMsg['post_text'] ?></p>
        </li>
        
        <li class="<?php echo $this->errorMsg['post_published'] ? 'error' : '' ?>">
            <label class="desc <?php echo $this->errorMsg['post_published'] ? 'error' : '' ?>">Data di Pubblicazione</label>
            <div class="float-left">
                <span class="input">
                    <input class="field text dateValid" name="day" id="day" size="2" type="text" maxlength="2" value="<?php echo $this->data['post_published_d'] ? $this->data['post_published_d'] : date( 'd' ) ?>" /> / 
                    <label>DD</label>
                </span>

                <span class="input">
                    <input class="field text dateValid" name="month" id="month" size="2" type="text" maxlength="2" value="<?php echo $this->data['post_published_m'] ? $this->data['post_published_m'] : date( 'm' ) ?>" /> / 
                    <label>MM</label>
                </span>

                <span class="input">
                    <input class="field text dateValid" name="year" id="year" size="4" type="text" maxlength="4" value="<?php echo $this->data['post_published_y'] ? $this->data['post_published_y'] : date( 'Y' ) ?>" />
                    <label>YYYY</label>
                </span>

<!--		<span class="input">
<img alt="Pick a date." src="/images/admin/calendar.png" onclick="$('#datepicker').trigger('click');" class="datepicker" id="datepicker">
            </span>-->
            </div>
            <p class="error" style="<?php echo $this->errorMsg['post_published'] ? 'display:block' : '' ?>"><?php echo $this->errorMsg['post_published'] ?></p>
            <p id="instruct2" class="instruct">
                <small>Inserisci la data di pubblicazione del post.
                    <br/>Questo verr&agrave; visualizzato online a partire dalla data inserita.</small>
            </p>
        </li>

        <li>
            &nbsp;
        </li>
    </ul>

</div>
<div id="formButtons">
    <button id="conferma" name="conferma" value="conferma" class="button positive">
	<img src="/images/admin/tick.png" alt="" />Continua
    </button>
    <a id="annulla" name="annulla" value="annulla" class="button negative" href="#">
	<img src="/images/admin/cross.png" alt="" />Annulla
    </a>
</div>
</form>

